Stats
# Normality
## D'Agostino-Pearson normality test ("omnibus K2" test) - Parametric data here
## Null (H0): The data are normally distributed Alternate/the data are sampled from a Gaussian distribution
## The low p-value (<0.05) indicates you reject that null hypothesis and so accept the alternative hypothesis that the data are not sampled from a Gaussian population
## https://www.rdocumentation.org/packages/PoweR/versions/1.0.7/topics/statcompute
## in this case, all notmally distributed, therefore one-way anova is chosen
## ST1: non-parametric
df_ST1_WT <- df_abxinfantis_ST1 %>%
filter(Genotype == "WT")
df_ST1_KO <- df_abxinfantis_ST1 %>%
filter(Genotype == "KO")
statcompute(6,df_ST1_WT$`log10_copies_g_tissue`, levels = c(0.05), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL) # non-prametric
## $statistic
## [1] NaN
##
## $pvalue
## [1] NaN
##
## $decision
## [1] 0
##
## $alter
## [1] 3
##
## $stat.pars
## [1] NA
##
## $symbol
## [1] "K^2"
statcompute(6,df_ST1_KO$`log10_copies_g_tissue`, levels = c(0.05), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL)
## $statistic
## [1] NaN
##
## $pvalue
## [1] NaN
##
## $decision
## [1] 0
##
## $alter
## [1] 3
##
## $stat.pars
## [1] NA
##
## $symbol
## [1] "K^2"
## ST2: non-parametric
df_ST2_WT <- df_abxinfantis_ST2 %>%
filter(Genotype == "WT")
df_ST2_KO <- df_abxinfantis_ST2 %>%
filter(Genotype == "KO")
statcompute(6,df_ST2_WT$`log10_copies_g_tissue`, levels = c(0.05), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL) # non-prametric
## $statistic
## [1] NaN
##
## $pvalue
## [1] NaN
##
## $decision
## [1] 0
##
## $alter
## [1] 3
##
## $stat.pars
## [1] NA
##
## $symbol
## [1] "K^2"
statcompute(6,df_ST2_KO$`log10_copies_g_tissue`, levels = c(0.05), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL)
## $statistic
## [1] NaN
##
## $pvalue
## [1] NaN
##
## $decision
## [1] 0
##
## $alter
## [1] 3
##
## $stat.pars
## [1] NA
##
## $symbol
## [1] "K^2"
## LT: : non-parametric
df_LT_WT <- df_abxinfantis_LT %>%
filter(Genotype == "WT")
df_LT_KO <- df_abxinfantis_LT %>%
filter(Genotype == "KO")
statcompute(6,df_LT_WT$`log10_copies_g_tissue`, levels = c(0.05), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL) # non-prametric
## $statistic
## [1] NaN
##
## $pvalue
## [1] NaN
##
## $decision
## [1] 0
##
## $alter
## [1] 3
##
## $stat.pars
## [1] NA
##
## $symbol
## [1] "K^2"
statcompute(6,df_LT_KO$`log10_copies_g_tissue`, levels = c(0.05), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL)
## $statistic
## [1] NaN
##
## $pvalue
## [1] NaN
##
## $decision
## [1] 0
##
## $alter
## [1] 3
##
## $stat.pars
## [1] NA
##
## $symbol
## [1] "K^2"
# If the normality results are not consistent for different tisses, I will classify them as non-parametric data for consistency as they are in one figure. In this case, they will be considered as non-parametric data, thus, Mann-whitney tests were employed.
# Summary of data
## ST1
Summary_ST1 <- df_abxinfantis_ST1 %>%
group_by(Genotype) %>%
summarise(
count = n(),
median= median (log10_copies_g_tissue, na.rm=TRUE),
IQR = IQR (log10_copies_g_tissue,na.rm=TRUE),
IQR25 = quantile(log10_copies_g_tissue, 0.25),
IQR75 = quantile(log10_copies_g_tissue, 0.75)
)
Summary_ST1
## # A tibble: 2 × 6
## Genotype count median IQR IQR25 IQR75
## <fct> <int> <dbl> <dbl> <dbl> <dbl>
## 1 WT 5 3.56 0.509 3.42 3.93
## 2 KO 5 2.58 0 2.58 2.58
## ST2
Summary_ST2 <- df_abxinfantis_ST2 %>%
group_by(Genotype) %>%
summarise(
count = n(),
median= median (log10_copies_g_tissue, na.rm=TRUE),
IQR = IQR (log10_copies_g_tissue,na.rm=TRUE),
IQR25 = quantile(log10_copies_g_tissue, 0.25),
IQR75 = quantile(log10_copies_g_tissue, 0.75)
)
Summary_ST2
## # A tibble: 2 × 6
## Genotype count median IQR IQR25 IQR75
## <fct> <int> <dbl> <dbl> <dbl> <dbl>
## 1 WT 5 5.07 1.62 3.80 5.41
## 2 KO 5 3.42 1.22 2.58 3.80
## LT
Summary_LT <- df_abxinfantis_LT %>%
group_by(Genotype) %>%
summarise(
count = n(),
median= median (log10_copies_g_tissue, na.rm=TRUE),
IQR = IQR (log10_copies_g_tissue,na.rm=TRUE),
IQR25 = quantile(log10_copies_g_tissue, 0.25),
IQR75 = quantile(log10_copies_g_tissue, 0.75)
)
Summary_LT
## # A tibble: 2 × 6
## Genotype count median IQR IQR25 IQR75
## <fct> <int> <dbl> <dbl> <dbl> <dbl>
## 1 WT 5 6.65 0.783 5.99 6.78
## 2 KO 5 2.58 1.33 2.58 3.91
# Mann-whitney test
## ST1
stats_ST1 <- wilcox.test(log10_copies_g_tissue ~ Genotype, data=df_abxinfantis_ST1,
paired=FALSE, correct=TRUE, conf.int=TRUE, conf.level=0.95, exact=FALSE)
stats_ST1
##
## Wilcoxon rank sum test with continuity correction
##
## data: log10_copies_g_tissue by Genotype
## W = 21, p-value = 0.08467
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
## -0.6180822 3.0723308
## sample estimates:
## difference in location
## 0.986382
## ST2
stats_ST2 <- wilcox.test(log10_copies_g_tissue ~ Genotype, data=df_abxinfantis_ST2,
paired=FALSE, correct=TRUE, conf.int=TRUE, conf.level=0.95, exact=FALSE)
stats_ST2
##
## Wilcoxon rank sum test with continuity correction
##
## data: log10_copies_g_tissue by Genotype
## W = 21, p-value = 0.09369
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
## -0.2448975 2.8339044
## sample estimates:
## difference in location
## 1.305224
## LT
stats_LT <- wilcox.test(log10_copies_g_tissue ~ Genotype, data=df_abxinfantis_LT,
paired=FALSE, correct=TRUE, conf.int=TRUE, conf.level=0.95, exact=FALSE)
stats_LT
##
## Wilcoxon rank sum test with continuity correction
##
## data: log10_copies_g_tissue by Genotype
## W = 25, p-value = 0.01116
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
## 1.665608 5.888703
## sample estimates:
## difference in location
## 3.414258
Plot
# Draw bar plot
set.seed(123)
# One figure
figure <- ggbarplot(
df_all_abxinfantis, x = "TissueType", y = "log10_copies_g_tissue",
add = c("median_iqr", "jitter"),
add.params = list(shape = "Genotype"),
fill= "Genotype", palette = c("#807F7F", "#BF504D"),
position = position_dodge(0.8)
)+
labs(x="", y=expression(atop('B. infantis',paste('(log'['10']*'copies/g tissue)'), side=2, line=2)), caption ="")+
theme(legend.position = "bottom",
axis.text.x=element_text(colour="black", face="plain", size=14),
axis.text.y=element_text(colour="black", face="plain", size=14),
axis.title.x=element_text(margin = margin(t = 10)),
axis.title.y=element_text(margin = margin(r = 10), size=16),
axis.title = element_text(face="plain", size = 10),
plot.title = element_text(size=16, hjust = 0.5),
panel.grid = element_blank(),
panel.border = element_rect(color="black", #element_rect is often used for backgrounds and borders
fill = NA,
size = 1),
legend.background = element_rect(color="transparent"),
aspect.ratio = 0.3,
plot.background = element_rect(fill="transparent", colour = "transparent"))+
scale_fill_manual(values=alpha(c("#30436d","#654e3a"),0.8))+ #BC3C29B2 and #0072B5B2,"#374E55B2" and "#DF8F44B2"
coord_cartesian(ylim=c(0,10))+
scale_y_continuous(breaks = seq(0,10,2))
figure

figure <- ggplot(data = df_all_abxinfantis %>%
group_by(TissueType,Genotype) %>%
ungroup(),
aes(x=TissueType, y=log10_copies_g_tissue, color=Genotype))+
geom_bar(data = df_all_abxinfantis %>%
group_by(TissueType,Genotype) %>%
summarise(mediancopies=median(log10_copies_g_tissue)) %>%
ungroup(),
aes(x=TissueType, y=mediancopies, fill=Genotype),
width = 0.5,
stat = "identity",
color="black",
position=position_dodge(width=0.7))+
geom_jitter(aes(x=TissueType, y=log10_copies_g_tissue),size=2.5,
position = position_jitterdodge(jitter.width=0.3,dodge.width=0.7))+
labs(x="", y=expression(atop(italic("B. infantis"),paste('(log'['10']*'copies/g tissue)'), side=2, line=2)), caption ="")+
theme(legend.position = "bottom",
axis.text.x=element_text(colour="black", face="plain", size=18),
axis.text.y=element_text(colour="black", face="plain", size=18),
axis.title.x=element_text(margin = margin(t = 10)),
axis.title.y=element_text(margin = margin(r = 10), size=18),
axis.title = element_text(face="plain", size = 10),
plot.title = element_text(size=16, hjust = 0.5),
panel.grid = element_blank(),
panel.border = element_rect(color="black", #element_rect is often used for backgrounds and borders
fill = NA,
size = 1),
panel.background = element_rect(fill="transparent", colour = "transparent"),
legend.background = element_rect(color="transparent"),
aspect.ratio = 0.25,
plot.background = element_rect(fill="transparent", colour = "transparent"))+
scale_fill_manual(values=alpha(c("#30436d","#654e3a"),0.8))+ #BC3C29B2 and #0072B5B2,"#374E55B2" and "#DF8F44B2"
scale_color_manual(values=alpha(c("black","black"),0.6))+
coord_cartesian(ylim=c(0,12))+
scale_y_continuous(breaks = seq(0,12,2))
figure
